<!--
侧边栏(分类)组件

Events:
category-selected(e: num)

categories: [
  {
    id: int,
    name: str
  }
]
-->
<template>
  <div>
    <el-menu default-active="all" @select="selected">
      <el-menu-item index="all">全部</el-menu-item>
      <el-menu-item v-for="i in categories" :key="i.id" :index="i.id">
        {{ i.name }}
      </el-menu-item>
    </el-menu>
  </div>
</template>

<script>
export default {
  name: "SideBar",
  props: {
    categories: Array
  },
  methods: {
    selected(index) {
      this.$emit("category-selected", index)
    }
  }
}
</script>

<style scoped>

</style>